package order

import (
	"github.com/shopspring/decimal"
	"time"
)

type OrderDTO struct {
	TradeNo         string          `validate:"required"`         // 交易单号
	Status          int             `validate:"required,numeric"` //  交易状态:0=已下单，1=已支付，2=已配送 3=已取消
	Source          int             `validate:"required,numeric"` // 交易来源：0=自建，1=jd，2=美团，3=饿了么，4=天猫，5=淘宝等等
	PayType         int             `validate:"required,numeric"` //支付类型 1：线下支付2：在线支付
	SaleAmount      decimal.Decimal `validate:"required,numeric"` // 销售金额
	PrivilegeAmount decimal.Decimal `validate:"required,numeric"` //优惠金额
	TradeAmount     decimal.Decimal `validate:"required,numeric"` //交易金额
	PayAmount       decimal.Decimal `validate:"required,numeric"` //支付金额
	BizDate         time.Time       ``                            // 交易日
}

func (o *OrderDTO) FromCreatedDTO(dto *OrderCreatedDTO) {
	o.Source = dto.Source
	o.PayType = dto.PayType
	o.SaleAmount = dto.SaleAmount
	o.PrivilegeAmount = dto.PrivilegeAmount
	o.TradeAmount = dto.TradeAmount
	o.PayAmount = dto.PayAmount
}

type OrderCreatedDTO struct {
	Source          int             `validate:"numeric"` // 交易来源：0=自建，1=jd，2=美团，3=饿了么，4=天猫，5=淘宝等等
	PayType         int             `validate:"numeric"` //支付类型 1：线下支付2：在线支付
	SaleAmount      decimal.Decimal `validate:"numeric"` // 销售金额
	PrivilegeAmount decimal.Decimal `validate:"numeric"` //优惠金额
	TradeAmount     decimal.Decimal `validate:"numeric"` //交易金额
	PayAmount       decimal.Decimal `validate:"numeric"` //支付金额
}

type OrderChangeStatusDTO struct {
	TradeNo string `validate:"required"`         // 交易单号
	Status  int    `validate:"required,numeric"` //  交易状态:0=已下单，1=已支付，2=已配送 3=已取消
}
